package com.yanqu.road.server.cmd.activity.commonsupport;

import com.yanqu.road.entity.enums.eLogMoneyType;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.pb.activity.CommonUnionSupportProto;
import com.yanqu.road.server.cmd.base.AbstractCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.gameplayer.module.player.CurrencyModule;
import com.yanqu.road.server.protocol.Protocol;

@Cmd(code = Protocol.S_COMMON_UNION_SUPPORT_FROM_CROSS,desc = "支持商会")
public class DoUnionSupportFromCrossCmd extends AbstractCommand {

    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        return true;
    }

    @Override
    public void execute(GamePlayer player, YanQuMessage packet) throws Exception {
        CommonUnionSupportProto.DoUnionSupportResp resp = CommonUnionSupportProto.DoUnionSupportResp.parseFrom(packet.getBytes());
        if(player != null){
            player.getModule(CurrencyModule.class).addCurrency(resp.getReward(), eLogMoneyType.Activity, eLogMoneyType.ActivityCommonSupportReward);
            player.sendPacket(Protocol.U_COMMON_UNION_SUPPORT, resp.toBuilder());
        }else {
           log.error("player {}, add reward {}, offline", packet.getPlayerId(), resp.getReward());
        }
    }

    @Override
    public void sendData(GamePlayer player) {

    }
}
